package com.xqboss.common.enums;

import org.springframework.lang.Nullable;

import java.util.HashMap;
import java.util.Map;

/**
 * 业务类别（短信发送）
 *
 * @author Administrator
 */
public enum MessageSendEnum {

    /**
     * 登录
     */
    LOGIN,

    /**
     * 注册
     */
    REGISTER,

    /**
     * 修改密码
     */
    FORGET_PASSWORD,

    /**
     * 通用类型
     */
    GENERAL_CODE;

    private static final Map<String, MessageSendEnum> mappings = new HashMap<>(16);

    static {
        for (MessageSendEnum messageSendEnum : values()) {
            mappings.put(messageSendEnum.name(), messageSendEnum);
        }
    }

    @Nullable
    public static MessageSendEnum resolve(@Nullable String method) {
        return (method != null ? mappings.get(method) : null);
    }

    public boolean matches(String method) {
        return (this == resolve(method));
    }

}

